package com.course.controller;

import com.api.entity.Course;
import com.api.entity.CourseComment;
import com.course.feign.CommentFeign;
import com.course.service.CourseService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/*
    @ClassName Controller
    @Description TODO
    @Date 2021/9/2、16:22
*/
@RestController
@RequestMapping("course")
@CrossOrigin
public class CourseController {

    @Resource
    private CommentFeign feign;

    @Resource
    private CourseService service;

    @RequestMapping("getAllCourse")
    public List<Course> getAllCourse(){

        return service.getAllCourse();
    }

    @RequestMapping("getMyCoursesById/{ids}")
    public List<Course> getMyCoursesById(@PathVariable("ids") List ids){
        List<Course> list = service.getCourseByPurchase(ids);
        return list;
    }
    @RequestMapping("/comment/getCourseCommentList/{courseId}/{pageNum}/{pageSize}")
    public List<CourseComment> getCourseCommentList(@PathVariable("courseId")Integer courseId,
                                                    @PathVariable("pageNum")Integer pageNum,
                                                    @PathVariable("pageSize")Integer pageSize){

        return feign.getAllComment(courseId,pageNum,pageSize);
    }

}
